package csxXiti.xiti4;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author WuYongheng
 * @date 2021/11/23
 * @description
 */

public class xiti4_2 {
    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<Integer, String>();
        map.put(1, "张三");
        map.put(2, "周四");
        map.put(3, "汪五");
        map.put(4, "赵六");

        //插入一个编码为 5 姓名为李晓红的信息
        map.put(5, "李晓红");
        // 移除编号为1的信息
        map.remove(1);
        //将 map 集合中编号为 2 的姓名信息修改为"周林"
        map.put(2, "周林");

        System.out.println(map.size());
        for (int i = 1; i <= map.size(); i++) {
            System.out.println(map.get(i));
        }

        Set<Integer> set = map.keySet();
        Iterator<Integer> it = set.iterator();
        while (it.hasNext()) {
            Integer key = it.next();
            System.out.println("序号为：" + key + "姓名为：" + map.get(key));
        }
    }
}